package vashion.azeroth.api.controller.tran;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import vashion.azeroth.api.controller.base.BaseController;
import vashion.azeroth.common.tran.transfer.OrderTransfer;
import vashion.azeroth.contant.TranErrorEnum;
import vashion.azeroth.core.personal.tran.pojo.PersonalDisburse;
import vashion.azeroth.core.result.ApiResult;
import vashion.azeroth.core.service.tran.PersonalDisburseService;

@Controller
@RequestMapping("tran")
public class ChangeOrderController extends BaseController {

	@Autowired
	private PersonalDisburseService<PersonalDisburse> disburseService;
	
	@RequestMapping("changeOrder")
	@ResponseBody
	public ApiResult<Boolean> changeOrder(String disburseNo, String type) {
		
		String supportType = OrderTransfer.getChangeType(type);
		if(null == supportType) {
			return ApiResult.newErrorResult(TranErrorEnum.ORDER_TYPE_ERROR.getErrorCode(), "修改订单" + TranErrorEnum.ORDER_TYPE_ERROR.getErrorMessage());
		}
		
		return disburseService.changeOrder(disburseNo, type);
	}
}
